<h:panelGrid xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:t="http://myfaces.apache.org/tomahawk" width="100%"
	id="pnlContactPerson">
	<p:panel id="contactPersonInfo">
		<p:panelGrid style="width:100%" >
			<h:inputHidden value="#{evokPatientBean.contactPerson.id}" />
			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.evok_contact_person_relationship} *" />
				</p:column>
				<p:column colspan="3">
					<p:selectOneMenu value="#{evokPatientBean.contactPerson.relationship}">
						<f:selectItem itemLabel="" itemValue="" />
						<f:selectItems value="#{sessionEnum['PatientRelationship']}" var="en" itemLabel="#{en.name}"
							itemValue="#{en.value}" />
					</p:selectOneMenu>
				</p:column>
			</p:row>
			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_surname} *" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.surname}" 
						style="width:95%" maxlength="40" />
				</p:column>
				<p:column>
					<h:outputLabel value="#{msgs.empl_name} *" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.name}" 
						style="width:95%" maxlength="40" />
				</p:column>
			</p:row>

			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_street} *" />
				</p:column>
				<p:column colspan="3">
					<p:inputText value="#{evokPatientBean.contactPerson.street}"
						style="width:95%" maxlength="80" />
				</p:column>
			</p:row>

			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_liveplace} *" />
				</p:column>
				<p:column colspan="3">
					<h:panelGrid columns="3" styleClass="tableNoBorder" style="width:95%">
						<p:selectOneMenu id="region3" value="#{evokPatientBean.contactRegionId}"
							converter="longConverter" style="width:220px;">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItems value="#{cityBean.regionList}" var="re" itemLabel="#{re.name}"
								itemValue="#{re.id}" />
							<p:ajax update="city3,postcode3" listener="#{evokPatientBean.contactRegionChange}" />
						</p:selectOneMenu>

						<p:selectOneMenu id="city3" value="#{evokPatientBean.contactCityId}" converter="longConverter">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItems value="#{evokPatientBean.contactCityList}" var="ct" itemLabel="#{ct.name}"
								itemValue="#{ct.id}" />
							<p:ajax update="postcode3" listener="#{evokPatientBean.contactCityChange}" />
						</p:selectOneMenu>

						<h:outputText value="#{evokPatientBean.contactPostcode}" id="postcode3" />
					</h:panelGrid>
				</p:column>
			</p:row>
			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_tel_home}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.tel1}" style="width:95%;" maxlength="40" />
				</p:column>
				<p:column>
					<h:outputLabel value="#{msgs.empl_tel_office}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.tel2}" style="width:95%;" maxlength="40" />
				</p:column>
			</p:row>

			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_mobile_home}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.mobHome}" style="width:95%;" maxlength="40" />
				</p:column>
				<p:column>
					<h:outputLabel value="#{msgs.empl_mobile_office}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.mobOffice}" style="width:95%;"
						maxlength="40" />
				</p:column>
			</p:row>

			<p:row>
				<p:column>
					<h:outputLabel value="#{msgs.empl_email1}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.email1}" style="width:95%;" maxlength="40" />
				</p:column>
				<p:column>
					<h:outputLabel value="#{msgs.empl_email2}" />
				</p:column>
				<p:column>
					<p:inputText value="#{evokPatientBean.contactPerson.email2}" style="width:95%;" maxlength="40" />
				</p:column>
			</p:row>
		</p:panelGrid>
		<f:facet name="footer">

				<p:commandButton value="#{msgs.button_submit}" icon="ui-icon-disk"
					actionListener="#{evokPatientBean.submitContactPerson}"
					oncomplete="wdgContactList.unselectAllRows();"
					update="contactlist,:messages,contactPersonInfo" process="contactPersonInfo">
				</p:commandButton>
				<p:spacer width="5"/>
				<p:commandButton value="#{msgs.button_reset}" icon="ui-icon-arrowrefresh-1-n"
					process="@this"
					actionListener="#{evokPatientBean.resetContactPerson}"
					update="contactPersonInfo,contactlist" />	

		</f:facet>
	</p:panel>

	<p:dataTable var="de" value="#{evokPatientBean.contactPersonModel}" selectionMode="single" 
		id="contactlist" widgetVar="wdgContactList">
		<p:ajax event="rowSelect" listener="#{evokPatientBean.selectContactPerson}"
			update=":mainform:paitentInfo:contactPersonInfo" />

		<p:column headerText="#{msgs.empl_surname}">
			<h:outputText value="#{de.surname}" />
		</p:column>

		<p:column headerText="#{msgs.empl_name}">
			<h:outputText value="#{de.name}" />
		</p:column>

		<p:column headerText="#{msgs.evok_contact_person_relationship}">
			<h:outputText value="#{de.relationship}" converter="enumConverter" enumName="PatientRelationship" />
		</p:column>

		<p:column headerText="#{msgs.table_column_operation}">
			<p:commandLink oncomplete="confirmContactPerson.show()" style="float:right;" immediate="true"
				styleClass="ui-icon ui-icon-trash" title="#{msgs.button_delete}" type="image">
				<f:setPropertyActionListener value="#{de}" target="#{evokPatientBean.contactPerson}" />
			</p:commandLink>
		</p:column>
	</p:dataTable>
</h:panelGrid>
